package com.ruoyi.system.service.impl;

import com.ruoyi.common.exception.BusiException;
import com.ruoyi.system.domain.UserRate;
import com.ruoyi.system.mapper.UserRateMapper;
import com.ruoyi.system.service.BaseServiceImpl;
import com.ruoyi.system.service.UserRateService;
import org.springframework.stereotype.Service;

@Service
public class UserRateServiceImpl extends BaseServiceImpl<UserRateMapper, UserRate> implements UserRateService {


    @Override
    public UserRate getUserRate(Long userId, String channelCode) {
        UserRate userRate = new UserRate();
        userRate.setUserId(userId);
        userRate.setChannelCode(channelCode);
        UserRate domain = this.getDomain(userRate);
        return domain;

    }

    public UserRate checkUserRate(Long userId, String channelCode) {

        UserRate domain = this.getUserRate(userId, channelCode);
        if (domain == null) {
            throw new BusiException("未配置通道费率");
        }
        return domain;

    }
}
